//
//  NotificationDetailVC.m
//  students
//
//  Created by 任辰东 on 2024/2/23.
//

#import "NotificationDetailVC.h"
#import "RCDTextFeidView.h"
#import "UILabel+LineSpace.h"
#import "NSNumber+Timestamp.h"
#import "NotificationApis.h"

@interface NotificationDetailVC ()
@property (nonatomic, strong) UIView *timeBgView;
@property (nonatomic, strong) UILabel *msgTimeLabel;

@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) NotificationModel *model;
@end

@implementation NotificationDetailVC

-(instancetype)initWithModel:(NotificationModel *)model
{
    self = [super init];
    if (self) {
        _model = model;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"查看";
    
    self.msgTimeLabel.text = [self.model.time dateStringWithFormat:@"MM-dd HH:mm"];
    [self.contentLabel setText:self.model.title lineSpacing:7];
    
    if (self.model.status.integerValue == 0) {
//        [self updateState];
        
        if (self.updateNotificationBlock) {
            self.updateNotificationBlock();
        }
    }
}

- (void)updateState
{
//    NSDictionary *params = @{
//        @"msg_id": self.model.ID,
//        @"user_id":[GVUserDefaults standardUserDefaults].uid};
//    
//    WeakSelf
//    [NotificationApis updataMsgRequestWithParams:params SuccessBlock:^(NSNumber *code, NSString *msg, id responseData) {
//    StrongSelf
//        if (self.updateNotificationBlock) {
//            self.updateNotificationBlock();
//        }
//        [[PushManager sharedInstance] setupPushNumber];
//    } FailureBlock:^(NSNumber *code, NSString *msg) {
//    
//    }];
}

-(void)setupViews
{
    [self.bgScrollView.contentView addSubview:self.timeBgView];
    [self.timeBgView addSubview:self.msgTimeLabel];
    [self.bgScrollView.contentView addSubview:self.containerView];
    [self.containerView addSubview:self.contentLabel];
    
}

-(void)setupLayout
{
    [self.timeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.bgScrollView.contentView).offset(20);
        make.centerX.equalTo(self.bgScrollView.contentView.mas_centerX);
    }];
    self.timeBgView.layer.cornerRadius = 3;
    self.timeBgView.layer.masksToBounds = YES;
    
    [self.msgTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.timeBgView).offset(5);
        make.left.equalTo(self.timeBgView).offset(15);
        make.bottom.equalTo(self.timeBgView).offset(-5);
        make.right.equalTo(self.timeBgView).offset(-15);
    }];
    
//    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.top.equalTo(self.bgScrollView.contentView).offset(10);
//        make.left.right.equalTo(self.bgScrollView.contentView);
//        make.height.mas_equalTo(50);
//    }];
    
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.timeBgView.mas_bottom).offset(15);
        make.left.equalTo(self.bgScrollView.contentView).offset(15);
        make.right.equalTo(self.bgScrollView.contentView).offset(-15);
        make.bottom.equalTo(self.bgScrollView.contentView);
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.containerView).offset(15);
        make.right.equalTo(self.containerView).offset(-15);
        make.bottom.equalTo(self.containerView).offset(-15);
        
    }];
}

#pragma mark -- lazyload

//-(RCDTextFeidView *)titleView
//{
//    if (!_titleView) {
//        RCDTextFeidViewModel *model = [RCDTextFeidViewModel new];
//        model.leftImgPath = @"baoxiu_dec";
//        model.leftTitle = @"内容";
//        model.alignment = NSTextAlignmentRight;
//        model.leftTitleFont = UIFontSize(16);
//        model.leftTitleColor = UIColorFromHex(kColorT2);
//        model.contentFont = UIFontSize(16);
//        model.contentColor = UIColorFromHex(kColorT3);
//        model.isNotEnable = YES;
//        _titleView = [[RCDTextFeidView alloc]initWithModel:model];
//        _titleView.backgroundColor = UIColorFromHex(kColorWhite);
//        [_titleView addTopLine];
//        [_titleView addBottomLineWithEdge:UIEdgeInsetsMake(0, 15, 0, 15)];
//    }
//    return _titleView;
//}

-(UIView *)containerView
{
    if (!_containerView) {
        _containerView = [UIView new];
        _containerView.backgroundColor = UIColorFromHex(kColorWhite);
        _containerView.layer.cornerRadius = 5;
        _containerView.layer.masksToBounds = YES;
    }
    return _containerView;
}

-(UILabel *)contentLabel
{
    if (!_contentLabel) {
        _contentLabel = [UILabel new];
        _contentLabel.font = UIFontSize(15);
        _contentLabel.textColor = UIColorFromHex(0x000000);
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}

-(UIView *)timeBgView
{
    if (!_timeBgView) {
        _timeBgView = [UIView new];
        _timeBgView.backgroundColor = UIColorFromHex(0xCCCCCC);
    }
    return _timeBgView;
}

-(UILabel *)msgTimeLabel
{
    if (!_msgTimeLabel) {
        _msgTimeLabel = [UILabel new];
        _msgTimeLabel.textColor = UIColorFromHex(kColorWhite);
        _msgTimeLabel.font = UIFontSize(13);
    }
    return _msgTimeLabel;
}

@end
